import 'package:flutter/material.dart';
import 'package:flutter_roujiaosuo/flutter_bloc/requests/models/SupplyModel.dart';
import 'package:rxdart/transformers.dart';

class SupplyItemView extends StatelessWidget {
  const SupplyItemView({Key key, this.itemClickBlock, this.model, this.height})
      : super(key: key);
  final itemClickBlock;
  final SupplyModel model;
  final double height;
  @override
  Widget build(BuildContext context) {
    String address = model.pubUser.vcompany == '1'
        ? model.pubUser.company
        : model.cangku + '  ' + model.truename;

    return InkWell(
      onTap: () => this.itemClickBlock(model),
      child: Stack(
        children: <Widget>[
          Container(
            margin: EdgeInsets.all(10),
            height: this.height - 20,
            child: Row(
              children: <Widget>[
                Container(
                  height: this.height - 20,
                  width: this.height - 20,
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(5)),
                      image: DecorationImage(image: NetworkImage(model.thumb))),
                ),
                Container(
                  width: MediaQuery.of(context).size.width - this.height,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Padding(
                        padding: const EdgeInsets.only(left: 8.0),
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: <Widget>[
                            SizedBox(
                              child: Text(
                                '${model.title}',
                                style: TextStyle(
                                    fontSize: 16, color: Colors.black87),
                              ),
                            ),
                            SizedBox(
                              child: Text(
                                address,
                                style: TextStyle(
                                    fontSize: 13, color: Colors.black87),
                              ),
                            ),
                            SizedBox(
                                child: Row(
                              children: <Widget>[
                                Container(
                                  margin: EdgeInsets.only(top: 3),
                                  padding: EdgeInsets.only(left: 3, right: 3),
                                  decoration: BoxDecoration(
                                    border: Border.all(
                                        color: Colors.green[200], width: 1),
                                    borderRadius: BorderRadius.all(
                                      Radius.circular(3),
                                    ),
                                  ),
                                  child: Text(
                                    '实名',
                                    style: TextStyle(
                                        color: Colors.green[200], fontSize: 10),
                                  ),
                                ),
                                model.pubUser.vcompany == '1'
                                    ? Container(
                                        margin:
                                            EdgeInsets.only(top: 3, left: 5),
                                        padding:
                                            EdgeInsets.only(left: 3, right: 3),
                                        decoration: BoxDecoration(
                                          border: Border.all(
                                              color: Colors.blue[200],
                                              width: 1),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(3),
                                          ),
                                        ),
                                        child: Text(
                                          '公司',
                                          style: TextStyle(
                                              color: Colors.blue[200],
                                              fontSize: 10),
                                        ),
                                      )
                                    : Container(),
                                model.ifprice == '1'
                                    ? Container(
                                        margin:
                                            EdgeInsets.only(top: 3, left: 5),
                                        padding:
                                            EdgeInsets.only(left: 3, right: 3),
                                        decoration: BoxDecoration(
                                          border: Border.all(
                                              color: Colors.green[400],
                                              width: 1),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(3),
                                          ),
                                        ),
                                        child: Text(
                                          '报价商',
                                          style: TextStyle(
                                              color: Colors.green[400],
                                              fontSize: 10),
                                        ),
                                      )
                                    : Container(),
                                double.parse(model.pubUser.deposit) > 2000
                                    ? Container(
                                        margin:
                                            EdgeInsets.only(top: 3, left: 5),
                                        padding:
                                            EdgeInsets.only(left: 3, right: 3),
                                        decoration: BoxDecoration(
                                          border: Border.all(
                                              color: Colors.yellow[400],
                                              width: 1),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(3),
                                          ),
                                        ),
                                        child: Text(
                                          '保证金',
                                          style: TextStyle(
                                              color: Colors.yellow[400],
                                              fontSize: 10),
                                        ),
                                      )
                                    : Container(),
                              ],
                            )),
                            Padding(
                              padding: const EdgeInsets.only(top: 3.0),
                              child: SizedBox(
                                child: Text(
                                  '产地：${model.chandi}',
                                  style: TextStyle(
                                      fontSize: 12, color: Colors.black87),
                                ),
                              ),
                            ),
                          ],
                        ),
                      ),

                      // Padding(
                      //       padding: EdgeInsets.only(top: 0),
                      //       child:
                      //     ),
                      // Padding(
                      //   padding: EdgeInsets.only(bottom: 0),
                      //   child: Text(
                      //     '￥${model.price}' + '元/${model.unit}',
                      //     style: TextStyle(
                      //         fontSize: 14, color: Colors.yellow[900]),
                      //   ),
                      // ),
                      // Column(
                      //   mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      //   crossAxisAlignment: CrossAxisAlignment.end,
                      //   children: <Widget>[

                      //   ],
                      // )
                    ],
                  ),
                ),
              ],
            ),
          ),
          Positioned(
              child: Text(
                '${model.edittime}',
                style: TextStyle(fontSize: 10, color: Colors.black54),
              ),
              right: 10,
              top: 10),
          Positioned(
              child: Text(
                '￥${model.price}' + '元/${model.unit}',
                style: TextStyle(fontSize: 14, color: Colors.yellow[900]),
              ),
              right: 10,
              bottom: 10),
          Positioned(
              bottom: 1,
              left: 10,
              right: 10,
              child: Container(
                color: Colors.grey[300],
                height: 1,
              )),
        ],
      ),
    );
  }
}
